/*
 * GRulesConstants.java
 * Created on 15 juil. 07
 *
 * Glacéo Internet Platform
 * http://sourceforge.net/projects/chm/
 *
 * Copyright (c) 2005-2008, Jens and Jan Janke (VirtualHockey Project)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.conf;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * Contains all kind of constants and static utility methods related to the actual rules
 * of a virtual hockey game and the organisation of a season.
 *
 * @version $Id$
 * @author jjanke
 */
public final class GRulesConstants
{
  /** Private constructor to avoid instantiation. */
  private GRulesConstants()
  {}

  /**
   * ID of the international association.
   */
  public static final String     ID_INTERNATIONAL_ASSOCIATION              = "EU";

  /**
   * ID of the special contest 'Champions League'.
   */
  public static final String     SPECIAL_CONTEST_ID_CHAMPIONS_LEAGUE       = "EU1";

  /**
   * ID of the special contest 'World League'.
   */
  public static final String     SPECIAL_CONTEST_ID_WORLD_LEAGUE           = "EU2";

  /**
   * ID of the first moveday in a season.
   */
  public static final int        ID_FIRST_MOVEDAY_OF_SEASON                = 1;

  /**
   * Max. number of league categories per association.
   */
  public static final int        MAX_NUM_LEAGUE_CATEGORIES                 = 5;

  /**
   * Convenience constant representing the cost of zero goals.
   */
  public static final BigDecimal ZERO_GOALS                                = new BigDecimal( "0.0" );

  /**
   * Indicates how much costs a goal scored at home.
   */
  public static final BigDecimal COST_HOME_GOAL                            = new BigDecimal( "0.9" );

  /**
   * Indicates how much costs a goal scored on the road.
   */
  public static final BigDecimal COST_AWAY_GOAL                            = new BigDecimal( "1.2" );

  /**
   * Indicates how much costs the shootout winning goal.
   */
  public static final BigDecimal COST_SHOOTOUT_WINNING_GOAL                = new BigDecimal( "0.5" );

  /**
   * Indicates how much bonus goals are awarded for the home team for each goal it has
   * scored more than its adversary who played on the road and lost.
   */
  public static final BigDecimal BONUS_HOME_GOAL                           = new BigDecimal( "0.2" );

  /**
   * Indicates how much bonus goals are awarded for the away team for each goal it has
   * scored more than its adversary who played at home and lost.
   */
  public static final BigDecimal BONUS_AWAY_GOAL                           = new BigDecimal( "0.3" );

  /**
   * Specifies the maximum number of goals a team can place for a single match.
   */
  public static final int        MAX_NUM_GOALS_PER_MATCH                   = 15;

  /**
   * Specifies the maximum number of matchdays that should take place on a single moveday.
   */
  public static final int        MAX_NUM_MATCHDAYS_PER_ROUND_ROBIN_MOVEDAY = 3;

  /**
   * Helper constant indicating the average number of goals scored by one team in a single
   * match. The factor 1.05 is added since the avg. cost of a goal is 1.05 ( (0.9 + 1.2) /
   * 2).
   */
  public static final double     GOALS_PER_MATCH_AVG                       = ( 5.25 / 2.0 ) * 1.05;

  /**
   * Returns the amount of bonus goals that should be added to the goal account of a team
   * that has the disadvantage of having to play the last (potentially decisive) match of
   * a KO series on the road.
   */
  public static final BigDecimal KO_MATCH_AWAY_TEAM_BONUS                  = COST_AWAY_GOAL.subtract( COST_HOME_GOAL ).multiply(
                                                                               BigDecimal.valueOf( GOALS_PER_MATCH_AVG * 0.5 ) ).setScale(
                                                                               1, RoundingMode.HALF_UP );

  /**
   * Coefficient by which points obtained during a league level 1 competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_LEAGUE_1     = BigDecimal.valueOf( 450, 1 );

  /**
   * Coefficient by which points obtained during a league level 2 competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_LEAGUE_2     = BigDecimal.valueOf( 375, 1 );

  /**
   * Coefficient by which points obtained during a league level 3 competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_LEAGUE_3     = BigDecimal.valueOf( 300, 1 );

  /**
   * Coefficient by which points obtained during a league level 4 competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_LEAGUE_4     = BigDecimal.valueOf( 225, 1 );

  /**
   * Coefficient by which points obtained during a league level 5 competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_LEAGUE_5     = BigDecimal.valueOf( 150, 1 );

  /**
   * Coefficient by which points obtained during a national cup competition for the
   * ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_NATIONAL_CUP          = BigDecimal.valueOf( 225, 1 );

  /**
   * Coefficient by which points obtained during the top level European competition for
   * the ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_EU1                   = BigDecimal.valueOf( 325, 1 );

  /**
   * Coefficient by which points obtained during the 2nd level European competition for
   * the ECR/ENR rankings are multiplied.
   */
  public static final BigDecimal CONTEST_COEFFICIENT_EU2                   = BigDecimal.valueOf( 275, 1 );
}
